<html>
<head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>第四章-安装Chapter&nbsp;4.&nbsp;Installing Gradle</title>
<link xmlns:xslthl="http://xslthl.sf.net" type="text/css"
	rel="stylesheet" href="../css/base.css">
<link xmlns:xslthl="http://xslthl.sf.net" type="text/css"
	rel="stylesheet" href="../css/docs.css">
<link xmlns:xslthl="http://xslthl.sf.net" type="text/css"
	rel="stylesheet" href="../css/userguide.css">
<meta content="DocBook XSL Stylesheets V1.75.2" name="generator">
<link rel="home" href="../userguide.html" title="Gradle User Guide">
<link rel="up" href="../userguide.html" title="Gradle User Guide">
<link rel="prev" href="../tutorials.html"
	title="Chapter&nbsp;3.&nbsp;Tutorials">
<link rel="next" href="../ch05/troubleshooting.html"
	title="Chapter&nbsp;5.&nbsp;Troubleshooting">
</head>
<body>
	<div class="navheader">
		<div>
			<div class="navbar">
				<a xmlns:xslthl="http://xslthl.sf.net" href="../tutorials.html"
					title="Chapter&nbsp;3.&nbsp;Tutorials">Previous</a><span>|</span><a
					xmlns:xslthl="http://xslthl.sf.net" href="../userguide.html"
					title="Gradle User Guide">Contents</a><span>|</span><a
					xmlns:xslthl="http://xslthl.sf.net" href="../ch05/troubleshooting.html"
					title="Chapter&nbsp;5.&nbsp;Troubleshooting">Next</a>
			</div>
		</div>
	</div>
	<div class="chapter">
		<div class="titlepage">
			<div>
				<div>
					<h1 xmlns:xslthl="http://xslthl.sf.net">
						<a name="installation"></a>第四章.&nbsp;安装
					</h1>
					<h3 xmlns:xslthl="http://xslthl.sf.net">
						<a name="installation"></a>Chapter&nbsp;4.&nbsp;Installing Gradle
					</h3>
				</div>
			</div>
		</div>
		<div class="section">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title">
							<a name="N10116"></a>4.1.&nbsp;先决条件
						</h2>
						<h4 class="title">
							<a name="N10116"></a>4.1.&nbsp;Prerequisites
						</h4>
					</div>
				</div>
			</div>
			<p>
				Gradle需要1.5或更高版本的JDK.Gradle自带了Groovy库,所以不需要安装Groovy.
				Gradle会忽略已经安装的Groovy.Gradle会使用ptah
				<sub>(这里的"path"应该是指PATH环境变量.[Rover12421]译注)</sub>
				中的JDK(可以使用<strong class="userinput"><code>java -version</code></strong>检查).
				当然,你可以配置<code class="envar">JAVA_HOME</code>环境变量来指向JDK的安装目录.
				<br>
				Gradle requires a Java JDK to be installed. Gradle requires a JDK
				1.5 or higher. Gradle ships with its own Groovy library, therefore
				no Groovy needs to be installed. Any existing Groovy installation is
				ignored by Gradle.Gradle uses whichever JDK it finds in your path
				(to check, use <strong class="userinput"><code>java
						-version</code></strong>). Alternatively, you can set the
				<code class="envar">JAVA_HOME</code>
				environment variable to point to the install directory of the
				desired JDK.
			</p>
		</div>
		<div class="section">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title">
							<a name="N10123"></a>4.2.&nbsp;下载
						</h2>
						<h4 class="title">
							<a name="N10123"></a>4.2.&nbsp;Download
						</h4>
					</div>
				</div>
			</div>
			<p>
				从<a class="ulink" href="http://www.gradle.org/downloads"
					target="_top">Gralde官方网站</a>下载Gradle的最新发行包<br> can download
				one of the Gradle distributions from the <a class="ulink"
					href="http://www.gradle.org/downloads" target="_top">Gradle web
					site</a>.
			</p>
		</div>
		<div class="section">
			<div class="titlepage">
				<div>
					<div>
					    <h2 class="title">
                            <a name="N1012C"></a>4.3.&nbsp;解压
                        </h2>
						<h4 class="title">
							<a name="N1012C"></a>4.3.&nbsp;Unpacking
						</h4>
					</div>
				</div>
			</div>
			<p>
			Gradle发行包是一个ZIP文件.完整的发行包包括以下内容<sub>(官方发行包有full完整版,也有不带源码和文档的版本,可根据需求下载.[Rover12421]译注)</sub>:<br>
			The Gradle distribution comes packaged as a ZIP. The full
				distribution contains:</p>
			<div class="itemizedlist">
				<ul class="itemizedlist">
					<li class="listitem"><p>Gradle可执行文件<br> The Gradle binaries.</p></li>
					<li class="listitem"><p>用户手册 (有PDF 和 HTML 两种版本)<br>The user guide (HTML and PDF).</p></li>
					<li class="listitem"><p>DSL参考指南<br>  DSL reference guide.</p></li>
					<li class="listitem"><p>API手册(Javadoc 和 Groovydoc)<br>The API documentation (Javadoc and
							Groovydoc).</p></li>
					<li class="listitem"><p>样例，包括用户手册中的例子,一些完整的构建样例和更加复杂的构建脚本 <br>Extensive samples, including the
							examples referenced in the user guide, along with some complete
							and more complex builds you can use the starting point for your
							own build.</p></li>
					<li class="listitem"><p>
					源代码.仅供参考使用,如果你想要自己来编译Gradle你需要从源代码仓库中检出发行版本源码,具体请查看<a
						class="ulink" href="http://www.gradle.org/development"
						target="_top">Gradle官方主页</a>.<br>
							The binary sources. This is for reference only. If you want to
							build Gradle you need to download the source distribution or
							checkout the sources from the source repository. See the <a
								class="ulink" href="http://www.gradle.org/development"
								target="_top">Gradle web site</a> for details.
						</p></li>
				</ul>
			</div>
		</div>
		<div class="section">
			<div class="titlepage">
				<div>
					<div>
					    <h2 class="title">
                            <a name="N10148"></a>4.4.&nbsp;配置环境变量
                        </h2>
						<h4 class="title">
							<a name="N10148"></a>4.4.&nbsp;Environment variables
						</h4>
					</div>
				</div>
			</div>
			<p>
			          运行gradle必须将
			    <code class="filename">
                    <em class="replaceable"><code>GRADLE_HOME/bin</code></em>
                </code>
                                          加入到你的
                <code class="envar">PATH</code>
                                          环境变量中.<br>
				For running Gradle, add
				<code class="filename">
					<em class="replaceable"><code>GRADLE_HOME</code></em>/bin
				</code>
				to your
				<code class="envar">PATH</code>
				environment variable. Usually, this is sufficient to run Gradle.
			</p>
		</div>
		<div class="section">
			<div class="titlepage">
				<div>
					<div>
					    <h2 class="title">
                            <a name="N10155"></a>4.5.&nbsp;测试安装
                        </h2>
						<h4 class="title">
							<a name="N10155"></a>4.5.&nbsp;Running and testing your
							installation
						</h4>
					</div>
				</div>
			</div>
			<p>
			          运行如下命令来检查是否安装成功.该命令会显示当前的JVM版本和Gradle版本.
			    <br>
			    <span class="command"><strong>gradle -v</strong></span>
                <br>
				You run Gradle via the <span class="command"><strong>gradle</strong></span>
				command. To check if Gradle is properly installed just type <span
					class="command"><strong>gradle -v</strong></span>. The output shows
				Gradle version and also local environment configuration (groovy and
				jvm version, etc.). The displayed gradle version should match the
				distribution you have downloaded.
			</p>
		</div>
		<div class="section">
			<div class="titlepage">
				<div>
					<div>
						<h2 class="title">
							<a name="N10160"></a>4.6.&nbsp;JVM 参数配置
						</h2>
						<h4 class="title">
                            <a name="N10160"></a>4.6.&nbsp;JVM options
                        </h4>
					</div>
				</div>
			</div>
			<p>
			Gradle运行时的JVM参数可以通过
			<code class="envar">GRADLE_OPTS</code>
			或
			<code class="envar">JAVA_OPTS</code>
			来设置.这些参数将会同时生效.
            <code class="envar">JAVA_OPTS</code>
			设置的参数将会同其它JAVA应用共享,一个典型的例子是可以在
			<code class="envar">JAVA_OPTS</code>
			中设置代理和
			<code class="envar">GRADLE_OPTS</code>
			设置内存参数.同时这些参数也可以在<span
				class="command"><strong>gradle</strong></span>或者<span
				class="command"><strong>gradlew</strong></span>脚本文件的开头进行设置.<br>
				JVM options for running Gradle can be set via environment variables.
				You can use
				<code class="envar">GRADLE_OPTS</code>
				or
				<code class="envar">JAVA_OPTS</code>
				. Those variables can be used together.
				<code class="envar">JAVA_OPTS</code>
				is by convention an environment variable shared by many Java
				applications. A typical use case would be to set the HTTP proxy in
				<code class="envar">JAVA_OPTS</code>
				and the memory options in
				<code class="envar">GRADLE_OPTS</code>
				. Those variables can also be set at the beginning of the <span
					class="command"><strong>gradle</strong></span> or <span
					class="command"><strong>gradlew</strong></span> script.
			</p>
		</div>
	</div>
	<div class="navfooter">
		<div>
			<div class="navbar">
				<a xmlns:xslthl="http://xslthl.sf.net" href="../ch03/tutorials.html"
					title="Chapter&nbsp;3.&nbsp;Tutorials">上一页</a><span>|</span><a
					xmlns:xslthl="http://xslthl.sf.net" href="../userguide.html"
					title="Gradle User Guide">返回目录</a><span>|</span><a
					xmlns:xslthl="http://xslthl.sf.net" href="../ch05/troubleshooting.html"
					title="Chapter&nbsp;5.&nbsp;Troubleshooting">下一页</a>
			</div>
		</div>
	</div>
</body>
</html>
